#ifndef HDOBJECT_H
#define HDOBJECT_H

#include <QObject>
#include <QPointF>
#include <GL\GLee.h>
#include <cxcore.h>

struct ThreeDimensionPoint
{
public:
	ThreeDimensionPoint()
	{
		x = 0;
		y = 0;
		z = 0;
	};

	ThreeDimensionPoint(float xco, float yco, float zco)
	{
		x = xco;
		y = yco;
		z = zco;
	};

	float x;
	float y;
	float z;
};

class HDObject : public QObject
{
	Q_OBJECT

public:
	HDObject(QObject *parent);
	~HDObject();

	float minHue();
	void setMinHue(float minH, bool update = true);

	float maxHue();
	void setMaxHue(float maxH, bool update = true);

	float minSaturation();
	void setMinSaturation(float minS, bool update = true);

	float maxSaturation();
	void setMaxSaturation(float maxS, bool update = true);

	float minValue();
	void setMinValue(float minV, bool update = true);

	float maxValue();
	void setMaxValue(float maxV, bool update = true);

	QPointF centroid();
	void setCentroid(QPointF centeroid);

	ThreeDimensionPoint* worldCoordinates();
	void setWorldCoordinates(float x, float y, float z);

	int pointsCount();
	void setPointsCount(int n);

	bool rangeHue();
	void enableRangeHue(bool enable, bool update = true);
	bool rangeSat();
	void enableRangeSat(bool enable, bool update = true);
	bool rangeVal();
	void enableRangeVal(bool enable, bool update = true);

	float searchRadius();
	void setSearchRadius(float radius);

	GLuint texOffScreen, texHueHist, texSatHist, texValHist;
	bool bCalcHueHist, bCalcSatHist, bCalcValHist;
	bool bAdaptiveHue, bAdaptiveSat, bAdaptiveVal;

	float hBins[ 360*4];
	float sBins[ 100*4];
	float vBins[ 100*4];
private:
	float _minH;
	float _maxH;
	float _minS;
	float _maxS;
	float _minV;
	float _maxV;

	bool bRangeHue, bRangeSat, bRangeVal;

	QPointF _centeroid;
	ThreeDimensionPoint _worldCoordinates;
	int _pointsCount;

	float _searchRadius;



};

#endif // HDOBJECT_H
